﻿#ifndef COMPLETEPORT_H
#define COMPLETEPORT_H
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#ifdef _WIN32
#include <winsock2.h>
#include <mswsock.h>

#include <stdio.h>

#define SOCKETNUMBER 1024
#define SOCKRECVSIZE 4096

#pragma comment(lib,"ws2_32.lib")
#pragma comment(lib,"mswsock.lib")

extern BOOL g_runFlag;
extern HANDLE *g_threadHead;
extern int g_threadNumber;

typedef struct SELOVERLAPPED
{
	OVERLAPPED overlap;
	int flag;
	char *buff;
}SELOVERLAPPED;

void InitComPort();
int createCompletePort();
int startThread();
DWORD WINAPI ThreadProc(LPVOID param);
void closeS();

int PostAccept();
int PostRecv(int index);
int PostSend(int index);

typedef int(*CallbackParser_IOCP)(char *Recvbuff, char *Sendbuff);
void SetCallbackFun_IOCP(CallbackParser_IOCP callback_IOCP);
#endif

#endif
